

//use "election_replication.dta", clear
use "C:\Users\w27484nm\Dropbox (The University of Manchester)\Brexit switchers\data\replication\election.dta", clear

// codebook:
// election: general election
//   1 - 2010
//   2 - 2015 
//   3 - 2017
//   4 - 2019
//
// votechoiceld: vote choice in general election
//   1 - Conservative
//   2 - Labour
//   3 - Lib Dem
//   4 - Other
//
// epvote2019: vote choice in 2019 European Parliament election
//   1 - Conservative
//   2 - Labour
//   3 - Lib Dem
//   4 - Brexit Party/UKIP
//   5 - Other
//
// em: ethnic minority status
//   0 - white British
//   1 - ethnic minority (one of Indian, Pakistani, Bangladeshi, black Caribbean or black African)
//
// leaver: supported leave or remain in wave 8 (2016-17)
//   0 - supported Remain
//   1 - supported Leave
//
// turnout: general election self-reported turnout
//   0 - report not voting
//   1 - report voting
//
// weight: survey weight
// pidp: cross-wave person identifier
// wave: survey wave (2, 7, 8, 9, 11)


////////////////////////////////////////////////////////////////////////////////
//This code reproduces the results visualized in Figure 1
////////////////////////////////////////////////////////////////////////////////
ta votechoice leaver if election==2 & em==1 [aw=weight], cell nofreq // 2015
ta votechoice leaver if election==4 & em==1 [aw=weight], cell nofreq // 2019



////////////////////////////////////////////////////////////////////////////////
//This code reproduces the results in the tables in the Online Appendix
////////////////////////////////////////////////////////////////////////////////


//Table 1: Proportion of Remain and Leave supporters voting for 
//  each party in 2015, 2017 and 2019 elections (general and European Parliament 
//  in 2019), ethnic minority respondents only

//Vote choice in elections by leave/remain status - ethnic minority voters
ta votechoiceld leaver if election==2 & em==1 [aw=weight], col
ta votechoiceld leaver if election==3 & em==1 [aw=weight], col
ta epvote2019 leaver if em==1 [aw=weight], col
ta votechoiceld leaver if election==4 & em==1 [aw=weight], col


//Same results but for white British voters instead - not in Table 1, but 
//  referred to in the text
ta votechoiceld leaver if election==2 & em==0 [aw=weight], col
ta votechoiceld leaver if election==3 & em==0 [aw=weight], col
ta epvote2019 leaver if em==0 [aw=weight], col
ta votechoiceld leaver if election==4 & em==0 [aw=weight], col


//Table 2: Proportion of Labour and Conservative voters who supported Remain and 
//  Leave in 2015, 2017 and 2019 general elections, ethnic minority respondents 
//  only
ta votechoiceld leaver if election==2 & em==1 [aw=weight], row
ta votechoiceld leaver if election==3 & em==1 [aw=weight], row
ta votechoiceld leaver if election==4 & em==1 [aw=weight], row

//Same results but for white British voters instead - not in Table 2, but
//  referred to in the text
ta votechoiceld leaver if election==2 & em==0 [aw=weight], row
ta votechoiceld leaver if election==3 & em==0 [aw=weight], row
ta votechoiceld leaver if election==4 & em==0 [aw=weight], row


//Are there turnout differences between Leavers and Remainers in 2019 and 2015?
ta leaver turnout if election==4 & em==1 [aw=weight], row // 2019
ta leaver turnout if election==2 & em==1 [aw=weight], row // 2015


